#include<iostream>
using namespace std;
typedef long long LL;
int n;
int cnt;
void dfs(LL last)
{
    if (last > n)return;
    if (last <= n) {
        cnt++;
        //cout<<"last=="<<last<<endl;
    }
    dfs(last * 10 + 4);
    dfs(last * 10 + 7);
}
int main()
{
    cin >> n;
    dfs(4);
    dfs(7);
    cout << cnt << endl;
    return 0;
}